<template>
	<view>
		<image src="../../static/settle/top.jpg" class="top-view"></image>
		<view class="center-view">
			<image src="../../static/settle/zmicon1.png" class="add-we"></image>
			<view class="from-view">
				<view class="from-input" style="margin-top: 0px;">
					<view class="input-title">姓名</view>
					<input class="input-text" type="text" placeholder="请输入姓名" v-model="form.username"/>
				</view>
				<view class="from-input">
					<view class="input-title">性别</view>
					<view style="display: flex;">
						<u-icon name="checkmark-circle-fill" color="#25c173" label="女" @click="gender(0)" v-if="form.gender == 0"></u-icon>
            <u-icon name="checkmark-circle" color="#999" label="女" @click="gender(0)" v-if="form.gender == 1"></u-icon>
						<view style="width:20rpx"></view>
						<u-icon name="checkmark-circle-fill" color="#25c173" label="男"  @click="gender(1)" v-if="form.gender == 1"></u-icon>
            <u-icon name="checkmark-circle" color="#999" label="男"  @click="gender(1)" v-if="form.gender == 0"></u-icon>
					</view>
				</view>
				<view class="from-input">
					<view class="input-title">类别</view>
					<view style="display: flex;
    color: grey;
    font-weight: 900;
    font-size: 16px;"  @click="show = true">
						{{cate_str}}
					</view>
				</view>
				<view class="from-input">
								<view class="input-title">意向城市</view>
								<view style="display: flex;
				color: grey;
				font-weight: 900;
				font-size: 16px;"  @click="cityshow = true">
									{{city_str}}
								</view>
							</view>
				<view class="from-input">
					<view class="input-title">手机号</view>
					<input class="input-text" type="text" placeholder="请输入手机号" v-model="form.mobile"/>
				</view>


			</view>
			<!--<image src="../../static/settle/zmicon2.png" class="zmicon"></image>
			<view class="btn-view">
				<view class="flex-column">
					<view style="font-size: 18px; color: rgb(51, 51, 51); font-weight: 600;">请上传本人近期照</view>
					<view style="font-size: 11px; color: rgb(138, 138, 138);">图片不得超过2M</view>
				</view>
				<image src="../../static/settle/addimg.png" style="width: 152px;height: 100px;"></image>
			</view>-->
		</view>

		<view class="subbtn flex flex-center" @click="submit()" v-if="user && user.is_technician!=1">提交</view>
		<view style="width:100%;height: 20rpx;"></view>
		<u-select v-model="show" :list="cate_list" value-name="id" label-name="name" @confirm="confirmcate" @cancel="cancelcate"></u-select>
    <u-select v-model="cityshow" :list="city_list" value-name="id" label-name="name" @confirm="confirmcity" @cancel="cancelcity"></u-select>
	</view>
</template>

<script>
	export default {
			data() {
				return {
					show: false,
          cityshow:false,
					cate_str:"请选择入驻类型",
          city_str:"请选择入驻城市",
          cate_list: [],
          city_list:[],
          form: {
            username: '',
            gender: 0,
            mobile: '',
            cate_id: '',
            city_id: '',
          },
					list: [
						{
							value: '1',
							label: '江'
						},
						{
							value: '2',
							label: '湖'
						}
					],
				}
			},
      onShow(){
        this.getCategory();
        this.getcity();
		this.user = uni.getStorageSync('userInfo')
		if(this.user.is_technician == 1){
			uni.showToast({
			  title: '您已是技师请勿重复申请',
			  icon: 'none'
			});
			return;
		}
      },
      methods: {
        gender(e){
          this.form.gender = e
        },
        submit() {
          let that = this
          if (!this.form.username) {
            uni.showToast({
              title: '请输入姓名',
              icon: 'none'
            });
            return;
          }
          if (!this.form.mobile) {
            uni.showToast({
              title: '请输入手机号',
              icon: 'none'
            });

            return;
          }
          if (!this.form.category_ids) {
            uni.showToast({
              title: '请选择入驻类型',
              icon: 'none'
            });

            return;
          }
          if (!this.form.city_id) {
            uni.showToast({
              title: '请选择入驻城市',
              icon: 'none'
            });
            return;
          }
          this.$http('technician.add', this.form).then(res => {
            uni.showToast({
              title: res.msg,
              icon: 'none'
            });
            if(res.code == 1){
            	setTimeout(function(){
            		uni.navigateBack({
            			data: 1
            		})
            	},1500)
            }
          });
        },
        confirmcate(e) {
          this.show = false;
          this.cate_str = e[0].label;
          this.form.category_ids = e[0].value;
        },
        cancelcate() {
          this.show = false;
        },
        confirmcity(e) {
          this.cityshow = false;
          this.city_str = e[0].label;
          this.form.city_id = e[0].value;
        },
        cancelcity() {
          this.cityshow = false;
        },
        getCategory() {
          this.$http('category.detail', {
            id:164,
            is_getCate:1
          }).then(res => {
            this.cate_list = res.data.children;
          });
        },
        getcity() {
          this.$http('category.city', {}).then(res => {
              this.city_list = res.data;
          });
        },
      }
		}
</script>

<style>
	page {
		background: #25c173;
	}

	.top-view {
		width: 100%;
		height: 448rpx;
	}

	.center-view {
		padding: 0px 16px;
		margin-top: -30px;
		position: relative;
		z-index: 10;
		overflow: hidden;
	}

	.add-we {
		width: 100%;
		height: 76rpx;
	}

	.from-view {
		border-left: 2px solid rgb(85, 85, 85);
		border-right: 2px solid rgb(85, 85, 85);
		padding: 40rpx 16px;
		margin: -7px 1px 0px 0px;
		background-color: white;
		color: #666;
		padding-top: 18px;
	}

	.from-input {
		white-space: nowrap;
		margin-top: 15px;
		border-radius: 10px;
		border: 2px solid rgb(36, 195, 115);
		height: 40px;
		padding: 0px 16px;
		display: flex;
		justify-content: space-between;
		align-content: center;
		align-items: center;
	}

	.input-title {
		font-size: 14px;
		color: rgb(138, 138, 138);
	}

	.input-text {
		font-size: 16px;
		color: rgb(51, 51, 51);
		font-weight: 600;
		text-align: right;
	}

	.zmicon {
		height: 29px;
		width: 99.8%;
		margin-left: 0.1%;
	}

	.btn-view {
		border-left: 2px solid rgb(85, 85, 85);
		border-right: 2px solid rgb(85, 85, 85);
		border-bottom: 2px solid rgb(85, 85, 85);
		padding: 0px 16px 16px;
		margin: -7px 1px 0px 0px;
		border-radius: 0px 0px 15px 15px;
		display: flex;
		justify-content: space-between;
		background-color: white;
		color: #666;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
		-webkit-flex-direction: column;
	}

	.subbtn {
		margin: 25px auto 40px;
		width: 311px;
		height: 48px;
		line-height: 48px;
		background: #fff474;
		border: 3px solid #000;
		box-shadow: 0 6px 0 #000;
		opacity: 1;
		border-radius: 50px;
		font-size: 18px;
		font-weight: 600;
		color: #000;
		display: flex;
		justify-content: center;
	}
</style>
